
import { http } from "@/utils/net/request";
import api from "./api";

export const wxLogin = (token: string) => {
    return http.post("", {
        sjdx: {
            dxdm: "SYS_QX_YHXX_MRDL"
        },
        sys: {
            cllx: "wxdl",
            token: token,
        }, yobj: {
            projectCode: api.PROJECT_CODE,
            model: "details"
        }
    }
    )
}

export const customReq = (data: any) => {
    return http.post("", data)
}

export const uploadFile = (file: any) => {
    return http.upload("",

        {
            files: [file],
            formData: { files: file, "sys.cllx": "upload", "yobj.sjzt": "default", "sys.authCode": "QTQX" },
            filePath: file.path, // 要上传文件资源的路径。
            name: 'files',
        })
}

//登录网络请求
export const login = (data: any, token?: string) => {
    return http.post("", {
        ...api.login, yobj: data, sys: {
            ...api.login.sys,
            token: token
        }
    })
};

export const logout = () => {
    return http.post("", api.logout)
};

export const getCds = (treeRoot: string) => {
    return http.post("", {
        ...api.getCds, yobj: {
            ...api.getCds.yobj,
            treeRoot: treeRoot
        }
    })
}

export const initSjdx = (dm: string) => {
    return http.post("", {
        ...api.initSjdx,
        sjdx: {
            dxdm: dm
        }
    }
    )
}

export const getSjdxList = (sjdx: any, page: any, yobj: any, searchKey: string) => {
    return http.post("", {
        ...api.getSjdxList, sys: {
            ...api.getSjdxList.sys,
            authCode: sjdx,
            searchKey: searchKey
        }, page: page, yobj: yobj,
    })

}

export const getXtjcxx = () => {
    return http.post("", api.getXtjcxx)
}

export const getSysVersion = () => {
    return http.post("", api.getSysVersion)
}

export const getDictList = (zdObj: any) => {
    return http.post("", { ...api.getDictList, yobj: { ...zdObj } })
}

export const getDictTree = (zdObj: any) => {
    return http.post("", { ...api.getDictTree, yobj: { ...zdObj } })
}

export const getDictSearch = (zdObj: any, page: any, searchKey: string) => {
    return http.post("", {
        ...api.getDictSearch, yobj: { ...zdObj }, page, sys: {
            ...api.getDictSearch.sys,
            searchKey: searchKey
        },
    })
}

export const getDictObj = (zdlb: string, dm: string) => {
    return http.post("", { ...api.getDictObj, yobj: { zdlb: zdlb, dm: dm } })
}

export const insertSjdx = (yobj: any, dxdm: string) => {
    return http.post("", { ...api.insertSjdx, yobj: yobj, sjdx: { dxdm: dxdm } })
}

export const updateSjdx = (yobj: any, dxdm: string) => {
    return http.post("", { ...api.updateSjdx, yobj: yobj, sjdx: { dxdm: dxdm } })
}

export const getSysList = () => {
    return http.post("", api.getSysList)
}

export const register = (data: any) => {
    return http.post("", { ...api.register, yobj: data })
}

export const updateUserInfo = (data: any) => {
    return http.post("", { ...api.updateUserInfo, yobj: data })
}
